package com.itheima.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealAndCheckGroupDao {

    @Insert("insert into t_setmeal_checkgroup(setmeal_id, checkgroup_id) VALUES (#{setmealId},#{checkGroupId});")
    void insert(Integer setmealId, Integer checkGroupId);

    /**
     * 通过setmealId删除t_setmeal_checkgroup表
     * @param setmealId
     */
    @Delete("delete from t_setmeal_checkgroup where setmeal_id=#{setmealId};")
    void delete(Integer setmealId);

    /**
     * 通过checkGroupId删除t_setmeal_checkgroup表
     * @param checkGroupId
     */
    @Delete("delete from t_setmeal_checkgroup where checkgroup_id=#{checkGroupId}")
    void deleteByCheckGroupId(Integer checkGroupId);

    @Select("select setmeal_id from t_setmeal_checkgroup where checkgroup_id=#{checkGroupId};")
    List<Integer> findByCheckGroupId(Integer checkGroupId);
}
